using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using Beaker.OpenCube.Render.Cameras;
using Beaker.OpenCube.Render.Lighting;
using Beaker.OpenCube.Render.Shapes;

namespace Beaker.OpenCube.Render
{
	public sealed class Scene
	{
		private readonly ICamera _camera;
		private readonly IReadOnlyCollection<IShape> _shapes;
		private readonly IReadOnlyCollection<ILight> _lights;
		private readonly AmbientLight _ambientLight;

		public Scene( ICamera camera, IEnumerable<IShape> shapes, IEnumerable<ILight> lights )
		{
			_camera = camera;
			_shapes = new ReadOnlyCollection<IShape>( ( shapes ?? new IShape[0] ).ToArray() );
			_lights = new ReadOnlyCollection<ILight>( ( lights ?? new ILight[0] ).ToArray() );

			_ambientLight = _lights.OfType<AmbientLight>().FirstOrDefault();
		}

		/// <summary>
		/// Gets the ambient lighting for the scene
		/// </summary>
		public AmbientLight AmbientLight
		{
			get { return _ambientLight; }
		}

		public ICamera Camera
		{
			get { return _camera; }
		}

		public IReadOnlyCollection<IShape> Shapes
		{
			get { return _shapes; }
		}

		public IReadOnlyCollection<ILight> Lights
		{
			get { return _lights; }
		}
	}
}